package com.bawei.module_apps

import android.content.Context

import com.bawei.library_base.BaseApplication
import com.bawei.module_apps.delegate.MyAppRequestListener
import com.bawei.module_apps.delegate.MyComponentDelegate
import com.bawei.module_apps.delegate.MyPhoneInfoDelegate
import com.bawei.module_apps.delegate.MyTaskDescriptionDelegate
import com.lody.virtual.client.core.VirtualCore
import com.lody.virtual.client.stub.VASettings

/**
 * @Author : 
 * @Time : On 2023/7/20 09:13
 * @Description : App
 */
class App: BaseApplication() {
    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        VASettings.ENABLE_IO_REDIRECT = true
        VASettings.ENABLE_INNER_SHORTCUT = false
        VirtualCore.get().startup(this) //开启虚拟机
    }

    override fun onCreate() {
        super.onCreate()
        //初始化
        val virtualCore = VirtualCore.get()
        virtualCore.initialize(object : VirtualCore.VirtualInitializer() {
            override fun onMainProcess() {
//                Once.initialise(this@App)
//                FlurryAgent.Builder()
//                    .withLogEnabled(true)
//                    .withListener {}
//                    .build(this@App, "48RJJP7ZCZZBB6KMMWW5")
            }

            override fun onVirtualProcess() {
                //listener components
                virtualCore.componentDelegate = MyComponentDelegate()
                //fake phone imei,macAddress,BluetoothAddress
                virtualCore.phoneInfoDelegate = MyPhoneInfoDelegate()
                //fake task description's icon and title
                virtualCore.taskDescriptionDelegate = MyTaskDescriptionDelegate()
            }

            override fun onServerProcess() {
                virtualCore.setAppRequestListener(MyAppRequestListener(this@App))
                virtualCore.addVisibleOutsidePackage("com.tencent.mobileqq")
                virtualCore.addVisibleOutsidePackage("com.tencent.mobileqqi")
                virtualCore.addVisibleOutsidePackage("com.tencent.minihd.qq")
                virtualCore.addVisibleOutsidePackage("com.tencent.qqlite")
                virtualCore.addVisibleOutsidePackage("com.facebook.katana")
                virtualCore.addVisibleOutsidePackage("com.whatsapp")
                virtualCore.addVisibleOutsidePackage("com.tencent.mm")
                virtualCore.addVisibleOutsidePackage("com.immomo.momo")
            }
        })

    }


}